package sk.avicularia.core.data;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import sk.avicularia.core.dao.AccessDAO;
import sk.avicularia.core.dao.PersonAccessDAO;
import sk.avicularia.core.dao.PersonDAO;

/**
 * Entita mapujuca strukturu PersonAccess
 * 
 * @author leaflock
 * @since 0.1
 */
@Entity
@Table(name = PersonAccessDAO.TABLE_NAME)
public class PersonAccess implements Serializable
{

	/**
	 * @see Serializable
	 */
	private static final long	serialVersionUID	= -7900388845536248074L;

	/**
	 * Id zaznamu
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable = false)
	private Long				id;

	/**
	 * Persona pre dany zaznam
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = PersonAccessDAO.COLUMN_ID_PERSON, referencedColumnName = "ID", table = PersonDAO.TABLE_NAME)
	private Person				person;

	/**
	 * Access pre dany zaznam
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = PersonAccessDAO.COLUMN_ID_ACCESS, referencedColumnName = "ID", table = AccessDAO.TABLE_NAME)
	private Access				access;

	@Embedded
	GeneralObjects				generalObjects;

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public Person getPerson()
	{
		return person;
	}

	public void setPerson(Person person)
	{
		this.person = person;
	}

	public Access getAccess()
	{
		return access;
	}

	public void setAccess(Access access)
	{
		this.access = access;
	}

	public GeneralObjects getGeneralObjects()
	{
		return generalObjects;
	}

	public void setGeneralObjects(GeneralObjects generalObjects)
	{
		this.generalObjects = generalObjects;
	}
}
